package ca.usherbrooke.domus.sipnmove2.view.call.impl;

import ca.usherbrooke.domus.sipnmove2.controller.call.SendSocketMessageActionController;
import ca.usherbrooke.domus.sipnmove2.controller.call.TerminateCallActionController;
import ca.usherbrooke.domus.sipnmove2.model.call.Call;
import ca.usherbrooke.domus.sipnmove2.view.call.CallView;
import ca.usherbrooke.domus.sipnmove2.view.call.CallViewFactory;

/**
 * Implementation of a call view factory
 */
public class CallViewFactoryImpl implements CallViewFactory {

	@Override
	public CallView createCallView(Call call) {
		CallView callView = new CallView();
		
		SendSocketMessageActionController sendMessageActionController = new SendSocketMessageActionController();
		sendMessageActionController.setCallView(callView);
		sendMessageActionController.setCall(call);

		TerminateCallActionController terminateCallActionController = new TerminateCallActionController();
		terminateCallActionController.setCall(call);
		
		callView.setSendMessageActionController(sendMessageActionController);
		callView.setTerminateCallActionController(terminateCallActionController);
		
		call.addCallObserver(callView);
		
		return callView;
	}

}
